{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "from rateLimiter import RateLimiter, set_log_level\n",
    "import cloudscraper\n",
    "from tqdm import tqdm\n",
    "import logging\n",
    "import timeit\n",
    "import copy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2025-03-16 12:56:17,838 - rateLimiter - INFO - Log level set to: 10\n"
     ]
    }
   ],
   "source": [
    "set_log_level(logging.DEBUG)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "items = [\n",
    "    {\"name\": \"Wrapped Greathelm\", \"refName\": \"Wrapped Greathelm\", \"namespace\": \"ITEM\", \"icon\": \"%NOT_FOUND%\", \"craftable\": {\"category\": \"Helmet\"}, \"armour\": {\"ar\": [79, 79]}, \"w\": 2, \"h\": 2},\n",
    "{\"name\": \"Wrapped Quarterstaff\", \"refName\": \"Wrapped Quarterstaff\", \"namespace\": \"ITEM\", \"icon\": \"%NOT_FOUND%\", \"craftable\": {\"category\": \"Warstaff\"}, \"w\": 2, \"h\": 4},\n",
    "{\"name\": \"Wrapped Sandals\", \"refName\": \"Wrapped Sandals\", \"namespace\": \"ITEM\", \"icon\": \"%NOT_FOUND%\", \"craftable\": {\"category\": \"Boots\"}, \"armour\": {\"es\": [22, 22]}, \"w\": 2, \"h\": 2},\n",
    "{\"name\": \"Astramentis\", \"refName\": \"Astramentis\", \"namespace\": \"UNIQUE\", \"unique\": {\"base\": \"Stellar Amulet\"}, \"icon\": \"https://web.poecdn.com/gen/image/WzI1LDE0LHsiZiI6IjJESXRlbXMvQW11bGV0cy9BbXVsZXQzNiIsInciOjEsImgiOjEsInNjYWxlIjoxfV0/95da0d04a4/Amulet36.png\"},\n",
    "{\"name\": \"Xoph's Breachstone\", \"refName\": \"Xoph's Breachstone\", \"namespace\": \"ITEM\", \"icon\": \"https://web.poecdn.com/gen/image/WzI1LDE0LHsiZiI6IjJESXRlbXMvQ3VycmVuY3kvQnJlYWNoL0JyZWFjaEZyYWdtZW50c0ZpcmUiLCJzY2FsZSI6MX1d/2fc9d593d6/BreachFragmentsFire.png\", \"craftable\": {\"category\": \"Breachstone\"}, \"w\": 1, \"h\": 1},\n",
    "{\"name\": \"Flash Grenade\", \"refName\": \"Flash Grenade\", \"namespace\": \"GEM\", \"icon\": \"%NOT_FOUND%\", \"craftable\": {\"category\": \"Active Skill Gem\"}, \"w\": 1, \"h\": 1, \"gem\": {\"awakened\": False, \"transfigured\": False}},\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "UNIQUE_FILTER = {\"type_filters\": {\"filters\": {\"rarity\": {\"option\": \"unique\"}}}}\n",
    "NONUNIQUE_FILTER = {\"type_filters\": {\"filters\": {\"rarity\": {\"option\": \"nonunique\"}}}}\n",
    "BASE_PAYLOAD = {\n",
    "    \"query\": {\n",
    "        \"status\": {\"option\": \"any\"},\n",
    "        \"stats\": [{\"type\": \"and\", \"filters\": []}],\n",
    "    },\n",
    "    \"sort\": {\"price\": \"asc\"},\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "url = \"https://www.pathofexile.com/api/trade2/search/Standard\"\n",
    "\n",
    "payload = {\n",
    "    \"query\": {\n",
    "        \"status\": { \"option\": \"online\" },\n",
    "        \"type\": \"Heavy Belt\",\n",
    "        \"stats\": [\n",
    "            {\n",
    "                \"type\": \"and\",\n",
    "                \"filters\": []\n",
    "            }\n",
    "        ]\n",
    "    },\n",
    "    \"sort\": { \"price\": \"asc\" }\n",
    "}\n",
    "headers = {\"content-type\": \"application/json\"}\n",
    "session = RateLimiter(debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2025-03-16 12:56:19,195 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): www.pathofexile.com:443\n",
      "2025-03-16 12:56:19,471 - urllib3.connectionpool - DEBUG - https://www.pathofexile.com:443 \"POST /api/trade2/search/Standard HTTP/11\" 200 None\n",
      "2025-03-16 12:56:19,472 - rateLimiter - DEBUG - Waiting for 28.0 | RateLimiter<max=30:window=300:penalty=1800>, RateLimiter<max=2:window=300:penalty=0>\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "< POST /api/trade2/search/Standard HTTP/1.1\n",
      "< Host: www.pathofexile.com\n",
      "< User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.4636.164 Mobile Safari/537.36\n",
      "< Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\n",
      "< Accept-Language: en-US,en;q=0.9\n",
      "< Accept-Encoding: gzip, deflate\n",
      "< content-type: application/json\n",
      "< Content-Length: 131\n",
      "< \n",
      "< {\"query\": {\"status\": {\"option\": \"any\"}, \"stats\": [{\"type\": \"and\", \"filters\": []}], \"type\": \"Heavy Belt\"}, \"sort\": {\"price\": \"asc\"}}\n",
      "\n",
      "> HTTP/1.1 200 OK\n",
      "> Date: Sun, 16 Mar 2025 17:56:35 GMT\n",
      "> Content-Type: application/json\n",
      "> Transfer-Encoding: chunked\n",
      "> Connection: keep-alive\n",
      "> Set-Cookie: POESESSID=a14b454a3ba88b8619c483a6c42f4c43; path=/; domain=.pathofexile.com; secure; HttpOnly; SameSite=Lax\n",
      "> Access-Control-Expose-Headers: X-Rate-Limit-Policy, X-Rate-Limit-Rules, X-Rate-Limit-Ip, X-Rate-Limit-Ip-State\n",
      "> X-Rate-Limit-Policy: trade-search-request-limit\n",
      "> X-Rate-Limit-Rules: Ip\n",
      "> X-Rate-Limit-Ip: 5:10:60,15:60:300,30:300:1800\n",
      "> X-Rate-Limit-Ip-State: 1:10:0,1:60:0,2:300:0\n",
      "> X-Frame-Options: SAMEORIGIN\n",
      "> Strict-Transport-Security: max-age=63115200; includeSubDomains; preload\n",
      "> Content-Encoding: gzip\n",
      "> cf-cache-status: DYNAMIC\n",
      "> vary: accept-encoding\n",
      "> Server: cloudflare\n",
      "> CF-RAY: 921620c6ec5f4dee-MCI\n",
      "> \n",
      "{\"id\":\"rW4QekRIQ\",\"complexity\":5,\"result\":[\"acf1c24b2f60ef893c263c28a937417c7a54f80a1c467330d825a16e5b9beb86\",\"b04083c86d99ef92a660f767218449eb5da30be4676712bb31fcaa76d0a7563e\",\"b3a35c05368fed1a96c45cd3fcbeaecb21191ed16474fdc26097ade8db6d61a7\",\"9a6607bc27fbea31a316157a14fec22b1365eab5fab5357b9f7f394e610cc211\",\"9d81f60fe358ff74dc9e69372f48ed7c00ccde9d21ea5bdcc7bd2e66091f569e\",\"93a82a43d34f988370f49b60dc217def55e9598806a1c0d9afa387874c764ed0\",\"bd771708fb2e45dc8525d75846f8a0b6c5f09c8b6a2c1516e539933ee82eabc0\",\"9b579065c174f373ae8f3907237c5120c662ea19ac72526b0a3ff0dd29fc0bbd\",\"e287578ed6e4619e658d3fb19a306a39e604e3b3ddfbed2884da73d73b323ce2\",\"30c06ef7115741b762888b90f48f9af3f81775276fa417a846ab79b76611fca0\",\"860f5fcfafb3a54a0bbbd4f7dd447f2f663f73348e3c62373072fbe0b43d5ac5\",\"666c6a6bb0656e7eac48ed75637f4f4668fc56de69b1cb1a5577d5618809aab7\",\"599f19446f1bc11278a9802c637bad7b0b866010124a6c4405f67002c44697a7\",\"a0f9ca42f9fc71baba321848da35d0839e59bb632eb74831b64ad1f5ba240c8b\",\"a7a3bc977bff7ebda70f935b5e747ec28f123ebc26ade173813085731eadc80b\",\"16db13e8ac90dfbf1e7c2fbf546f2dc80ffe09fdeaafc0eaa5bafd49c8b21851\",\"abfdf0e499cfb6f6a2c485717b0d71937921f636df642de76fd14b97cdc6b156\",\"630e17337c4db1ee40b3fb52eb8d374af8aaa6c3aa1629b96023e11a1e650e7d\",\"d54269e210f08aab7d08315ffac2cfeb3df6cfc9656702da4c36a2e4f161b7c6\",\"4a6724905ed3454c7e99846e262954fcc2acd97d127766c1c48675e82b2bf21a\",\"e18319c2ee42e715cf93c12f62949b3233d15b9bff0737039c6b9d150a096491\",\"04066eccbdbf14bb3de94ce9c57343fee946df76deb9357416950d3e58453606\",\"8ab58cb98fb8cde6754bcd04f401e359617f32a5234574359190a5e85eba93ed\",\"bf4ba536072eb7b0b6effa627f46e3f3dcbc51512702fe406eaca6090be19739\",\"19b5967a2f604de39ab4182429f14e793d0771aba2096a2e9eb042a8b7777696\",\"a46f357d23723108396678361c3163046ce5e8bc8271fc58d72a56f1e47459e6\",\"82a79dba5a3fe883457310ab55bb929fc29f4ff1402c4278740068d4d9de6c9c\",\"dffa44071f1a39442f11ae5db8355a9dcb0be29f506740f82f97defadb785668\",\"77b6bea9df1f49f42ebda6b182bad8058f08bcb7076cc4e08ae402a207d6fc15\",\"41fa4b2fbf2fccacbd8f28c5bb96208d96224615b7e1f2c95d1089a14bc6c83a\",\"25586c6e5067c28d12a88b60fa2c9f31dc45ea6230931d87766cde4035fedaa6\",\"5d1d7ac5534c0127a3fe7da71288b4703e071a03557fb69bb025ef42076cacaf\",\"7235535d8c4ed19ec00329910f7449225558af4cb2a26b050cb170574e6ca0ca\",\"a3861bc6f310670b28eb597afe244b8051bb7b9c2b891fe260ee12a571097481\",\"ccaee4e534d69a2b2facf4d48891f4ed2ac9e098261ada2073ac23d8d8284ffe\",\"a67f777aa415c863cc45f520509a60305a8858e6849b67474947d1ed93c4aab5\",\"5c4a878b47b810c3e1fed687bae7db233ec05ecca07a37248a5d9747aa592d2d\",\"d5e53cbfd1a11d77630ae545194cd64e5bc50a7f6aa52c2446598894dacb96f0\",\"b48addf8f19de884f836ac1c3b384f7364905487d9d7587799c514c0aa523c16\",\"f68d4ae54c50b0f0fd2dbbfcccebbda3e662de802b6bb7fa512b6a9bfddf87c9\",\"3d66165a69dee7af262d0f7036fb4a1bea4225d78fe4ca873fc9d576ad969fbb\",\"0463b3a8923a7be54153a3fe92e493ca912fcded04b6f1a7011fbb6677ad95a5\",\"b411d5b71bfbd35e0028932bc785848b6544eae5cb814b69ea4173aabb684645\",\"c06fd308f31bfcded1c102528c82f034692db28c1446ee617109a0beb825d249\",\"f1900416ffa2cc8ac9a5fed688cf1c53cf0c37856216a3c30ac740de0771ac51\",\"3e7beebd3e2c1d353c6bb28a7edda933318e49b55ea72710a78d013c58d9dafc\",\"8f094a88d1d99347ff3b72b8c8bacf6a9ad1aeacddeb4cca8f48f937d816dfd9\",\"de167a23b8ebe1487f0c393f59261028c72a434b7e8d9276e17cd465d6dd1422\",\"d8610b8ca16b43a113f8d63ce62c0b6fd7642c12857e4f087caec5efddf3edfc\",\"3eb9daf2874fde77f6a2417d0223ad4976b25b4b116cbff857f7c40ce7d6f666\",\"6b147af5142177e55fd14ed3198ab7864a45be2d955c37f9ae9aa946b3fcb708\",\"96db35b7b91d5f21ed5da92365b558151cb38699d84cdbf9319f434c530bcab8\",\"c22435ac5245cd2714c83fe5024ee7bbd6694666f741ed8eb9d9c9d9b94f23ea\",\"ff145e59714c41acb34a37bf9b4ef0222fef1c59f7db1f63d97e84f2604a9619\",\"36066421222eb2245581c3664606bb3da592429b55f72dffa2d42e60fea7e3c3\",\"1dc6ac8417a86219af32b30df150c767d15d9dcb8e79ee7424bbc470df4544a1\",\"8f8012695dac5b721a08e2d6affe627614371b1ba00b07193bd769d6929c5c44\",\"a177f3604409439dfac61321207f8b3cc0bfb8d6920a6becfda2f74d8c10c484\",\"a61ed11794d0c568c13f991961092e191484913da4066281ba9d6838b732a34f\",\"9396bbbca48caf6e48d88addb029bde038ed4125975874e7235353a66bd81c84\",\"e1d508411d45c95cffd8babe9476ee65165ec7227ac2d5ab1000d1204bbf10b2\",\"1805ebbf148005270da0f22e647ce222a53d12ab5924c4bb364b465a35d37c7e\",\"e6e7a12b6990ceca51882ba0a1d30e407f97602a3c969577e1096eef625aa5bd\",\"ce740fc61ef3df9c4f010efcdb064065a1472953d3d19a75bdbaa899742eb6cd\",\"af7fb2079feb3464285b4244b54015a6b8f330531c7012bfbaa30241269ba484\",\"0b6c560fc7596b00512777953d4695524ce08829af9b98b12954689efe6e34e9\",\"de7dcc290a8c32ce2b8c1a38fbe5949931247ec529e5e703193350d7bee66f7f\",\"80757cd076fdb36931de7d21961110ee958dc72476481e4c1523d212e9328802\",\"df0cdfc824e9a9df01fac08c980cba6cd437f39f3bf95ed353273b89b8320ba4\",\"2675e994310f3f14a663cba8b4e425e341b80cbc5fc79bb1eba0e57110a4966e\",\"752e6037dc84b158fc8caabf89a3635b0314d22152e2fedb8f22d29dbdefcff0\",\"860f6bfebb1e63467a639255ddfe34909c19033c404df967e87af572231ce26a\",\"05a193bcf4d256e1f9edb028651ed7b17a3113478a06ebecfa1d62031b8c3c4b\",\"9c7eec9f19f8f8f245e648410e6e769441cad85ecc4c3a7161036934cf52eb11\",\"d31ab705b147e344c0c1c6547af9f87b3458780191922348e64a67bb95dc874b\",\"d079fda54b20d0dfd600d1a86096faa414678c014b00478368c03604ba3f2ca5\",\"c56c10bcd7fd7e55b71a789a3fc7b5c385805f0a9fe1afdd8922b54a7b036a12\",\"4bf3800ad674c4cc35a9a1487acb295d1b069ae3bcde34e05aa9542de48e8714\",\"ae53f0c361a9626b02116a33024f6e5a256152265bfaa0b73c3a4ba9f56d14be\",\"6172254e41f6ef2fab2507dbe28fee2c40a72d73fe502f20d027b91bb51d88f3\",\"d63ae9c3203c88b593cdcbad3139abd6427cf8a9b0a069c229144eb2b737ac9c\",\"2793257a1326cf7fe6f26b43480f0e167b8a44f2fdcbd7d0ac19d843e6f4ef58\",\"67e9404ee06eeabaa43a37fbe0740184752e602c122e4eff300a6675eba46cd7\",\"44f3e3ae4498e81c4631115a35ccf68abae86e9d37ec3342d5c395df7aa273a9\",\"f3e96ee0d5b0c86d05011dbff1ed26bfe2fa335c26c3bd74758c6f9fd499fc3d\",\"0a16c16364546dbefe24dde847a15409b0b04d6667bf07d8e548e2569c6f2f7b\",\"5cccdb2bc60fba7554e868702cba7c97484189be06923686cf92ccb5db39f64a\",\"b52ffef000121d3714adc06897eee650c5f33c878b58620200b60dfc24ec1f21\",\"c4be8a064cfff879b432c2321bb28e5d4b4084ba060fe7ebf1d49ecfaf64e096\",\"83155b39e578152124fb3d952c9acc48e8857ad65577c39159f72fdaa57b3dc5\",\"416a81a1b9644bd8482142430e02efa09631c8863f6ebef3482b294f96f2d901\",\"fd2617684a46fae0bd1681fa79a276a6e572c439a49bb23db021e5a73fb8217f\",\"c66e1d1d635678e59bc40d05b5fa0e19641bcdfe14ef864b30bc0189d6b7f340\",\"3aa1b447507def8ac0e46a7606a60a524c498015ffc253b38a4976aa2bda858b\",\"557891e95138b006619d1cf5269438d27ad669f41c73ac644e0269939d1b054b\",\"1792c224aebad78260ba7cceb7e877fcdb2c50e564b7cc034579fabdda06969e\",\"0c6f011acec4629620baab9fc12058fcd980025808f381d96e090380ed3b915a\",\"f70e28ad9ca1971af8372915dd2254db18b5a4f8ebf7c6b02fb999f61fde41ed\",\"a1ab9058aa70b0863f944315eefe8325edf94f73b0bcd87ca80da8313fb72318\",\"3d87c69e300547df184bec3e52094c2473b8e75e49ccb10da59cea76e85cf43e\"],\"total\":10000,\"inexact\":true}\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2025-03-16 12:56:47,473 - rateLimiter - DEBUG - Current rate limits: defaultdict(None, {'trade-search-request-limit': {'policy': 'trade-search-request-limit', 'rules': 'Ip', 'limit': '5:10:60,15:60:300,30:300:1800', 'state': '1:10:0,1:60:0,2:300:0', 'rate_limits': [(RateLimiter<max=30:window=300:penalty=1800>, RateLimiter<max=2:window=300:penalty=0>), (RateLimiter<max=15:window=60:penalty=300>, RateLimiter<max=1:window=60:penalty=0>), (RateLimiter<max=5:window=10:penalty=60>, RateLimiter<max=1:window=10:penalty=0>)], 'last_update': datetime.datetime(2025, 3, 16, 12, 56, 19, 472912), 'prev_state': None, 'prev_rate_limits': None}})\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p = copy.deepcopy(BASE_PAYLOAD)\n",
    "p[\"query\"][\"type\"] = \"Heavy Belt\"\n",
    "\n",
    "\n",
    "session.post(\n",
    "    url,\n",
    "    payload=p,\n",
    "    headers=headers\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2025-03-13 21:06:23,872 - urllib3.connectionpool - DEBUG - Resetting dropped connection: www.pathofexile.com\n",
      "2025-03-13 21:06:24,063 - urllib3.connectionpool - DEBUG - http://www.pathofexile.com:80 \"POST /api/trade2/search/Standard HTTP/11\" 200 None\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "200\n",
      "{\"id\":\"aDaM4V3ue\",\"complexity\":5,\"result\":[\"fa0665087835d53ea92d73e5684fb19056b31f6a9e6dce6c74b44de289946bd5\",\"a81b2e3ff26541be20bf2affa42077bc82c7c75426efebcf4a84d2b7bf1dd43b\",\"943313b1a5345a82e4bbe0e4dbe3ca90e1d140c87a682d632ef5b2d74a031114\",\"76845362ff73808298f7a1aa53a318d1fcbb8de93d386d5733b4876399e8ca47\",\"fe013e1f4edabe371fc2c71162dfb6c850fcdcad27f334d1cd5a4fdc17d1500a\",\"e610aa90e9b075ff59c14dc3a89a569375d0dc701254e66e42f85b089526e105\",\"0b642c7894480411cd0f976f7898c0706789c01ebbf12dc18b3b600a9e523f9b\",\"4dd58b9011548c04979c6e4ae7a13c5d453d7159acc82a0aded315d5f3f181f6\",\"cc67b5a8d36b47369527666c89a140f8c9b19eaeb535480bcf55fb3a9633d5e0\",\"96915e45f2f015366879bed35ee656ff83336afcfe8d591cb6cf00d38814c495\",\"7476153e864807b4ad4402c61b6719e5d955062ff2393c7623f77bc5e26a8f07\",\"d708a0520ad799ed057578483220b72f705d09dd5a083b626d47f2a903f0ec32\",\"1f90566df8f2cc8314b182286b4566da959e496441ffcf707104aeaf52887f98\",\"17ada987bcca7748b1f364e96dab3b5f9d3a8403032bc9b77379870ecd7453a5\",\"7be5473d401b4c9319ee171f9aebcbfdcf3cbe75159aef04b9aeb022329b6654\",\"99fb5e07f90ec766299e0960a35afbb228d04854e7fd2258b2fd50dc8f20b9ed\",\"06cd27a5ef847e234a1e38c60bb5b2f50f5bc598b18b460a2837cf5e0c0b39aa\",\"bdce31eca9f7dfef431946c0c3dda44720ea57a5c28dcf8667a704217ad1bc17\",\"c9f865a995e42c6f053494ca83d7d7a5321c6025efb4783c689ffedcfaad92ad\",\"f7cb0a9e5fdecb5e1b10a6a53ec8bb6d887c77385cc3b8a9c175354c9c1a150d\",\"49cef220c06df33de17e8480dfa0ed49f5094924747f99cee47050f1863104a8\",\"47f31ee1bbd3b4f8a15e2afd10631ac877ea5f0e6d97bc7896b1c7b19cf0d47f\",\"1c5e1af9366b1004501f3c800850ba2306c7511f3537dcda20210f2bf1585d9e\",\"cf133494ac8d59dd9433c0eace032f7cf82b4448556bce3c9e72a4258a0a172a\",\"1673d4008f5ce8d8964b1c5231b85789e63fa6feefed4ab87e74e7ca5a1a8f84\",\"5d2f8177eef4efa9e4f132b2c90acdf5df1936e54a30ff45c9652dfc2a8e3a7b\",\"d06f85d446096d06cc2f39f026c3b3e464c0aac83282a17e6f1d2532818dc0d9\",\"da8fbe249526a8a42faa58630da09f192de3c63aa4236411278aaccffeb5bfec\",\"b99182bebc07e99182183e8c0afb73a9989db2dc7d035cdd3aad4d65ac382e00\",\"84148fb39f75ebbbe1dd43d7132ccc0ff2bd70985e2fe1bd4bc13c4a91184cfe\",\"710b0544c8345a9d9ef179119a126bf769e28e23a702a1951f78ce8f00a8828a\",\"86934641e28f018356e64a5e7e1472a962a0d5b807c4e61ef9844c5626cf3867\",\"bbcf25e860a451396b0eeaf1a689c8c400ee5a8372912e7f6d307da77e334350\",\"7b44541b4479bb425b4a4bed9d50929bd716c2c6c01b24b8b6537a7fb99b9aed\",\"66edc152ebaf76187675c447414a35fd36a48dc72f48bb1a1974b8098e55aa8d\",\"37d9cdf92d274d5d48f793d1c50cd0c9dc8d086ea185005d317ad23a11b83999\",\"c69cb3528f46d2a8fd62def892ba9b17061772fc5b71e76d9451ddc93299a176\",\"b1690ac348ead41be979cfd2894c4b35c5e43684ebb297e127c9287128660bf5\",\"59e38b89f5e43e1e5a4e9a940fdcd3ce708375f7352c973c3d58d8749b9eb024\",\"c4468e7c5383492b8146c5e472ed316d6e1daff7e320a1757d96f4de7203ec0c\",\"2518528659007fe220c0ec5aa9f710d70d9328771a887ff52179c857ad445f3d\",\"0d0a366db8563801f61c9e3bacefdfa477b96cae65e8d926d5d6053e9f127d32\",\"36fe75209f252e1bb4b46e0fced01cec4b1de4fe63195659cc3b4bc01dc4d13b\",\"5e6c1537623eca13b907469bd1a1e58cabe2b80d3f7ebd43ebd40cbd9e9cd869\",\"44162dba98620c23332a91de91534cda398dd8b5fdc44f461075337ecd78c674\",\"bc43da4157ccc6ebb02deee595e688d4c89efac79d393e05a60032b4c43c8c76\",\"878d7c7db3095f61402e610bff676f9da8b651b52b97c9d55bc35e1ccefc4cf8\",\"839b2bf64c33762bcc741f092c644944f3aa83c637fdcc1b6c9c05c822e708c8\",\"e3bc68a6dabc4a820a09bb2bc8dbbb4ac9bf22304090c301b329b9161bd51811\",\"760aac8c8e6b8d711169f7b63cec7c53b87db6d6e8ce3de4a171dfc3948fdb08\",\"fb04081a8ca3777eba57a666428280f02e4888ac9064257fbf9dfbbd92a7fd8d\",\"6e2fc60d5347131ae46dbfabe69e5026b6f183145059043bc3929a47cbd33921\",\"371d733a86b8caa1af9212a875d6592d3dc553d250e5753e24a303a8ff46cf28\",\"ba0e4d4172271cedec33cd471eb38131f90508c55e9e9e5b04bfd578eda2cbd1\",\"0ee5859f6290c048a65fddd7e558621d076d667d4a574e49879ede0a5056757e\",\"cae604ed8c692f6cab6ca574841bef60722de336e1fcaf9feff7a17bf19353f8\",\"d0e5e33eb8dcd36848809aab3bdeaf0811c26c8daacb0c060b2976ec2287dde0\",\"9fe6715f6f321bea3da84685dcaaa9f44a3e92d3d1fae95da751d3deece46e51\",\"41e0ec018d4eb898c30449dbc9a300fdbc9d5779f2c03e848f1d1beffb63fc8c\",\"7f71f54a49cd55f3772844835b5bcc5ed2465d458c01469083c8a47fa24994f3\",\"cdf50cf825379d768f4a1dff9c4eef6b7d54c2ad2fd2b010f8b0b7de12e31498\",\"fd2c93d0f187ea134b3e791ec701e83a00330b5fe519a091e08648da1896006d\",\"5dac24815890cea584bb7fe1d88c9444763f517cbaab2045612f00ab054410f0\",\"8ba990c5fd04680433409a964b824441b2e2f27559617709426e7ce0f43e13ed\",\"9e39832cd50cc19423cd9e897a2b89d0d3906620b9d2ca6453ea69773163354b\",\"7a0ed9168fcae933cf9ddd83bef28d6f83eea1a704e822701bdbb83dea89cfc0\",\"6887fbd99e3759382842b95e1a990f13032ed6915c759cf7b86a1b9339d540ab\",\"73854e750cd2e24864caa125b46b9cddc58ca7059b289abe53cace31db674223\",\"0e7ba9b6aa1e6653a8667c0b65111fed89a5eac6a48c41c3302e1445c045b17d\",\"a15c09ba2b01ebf29cd1d5e42510e2b8dd27487042d40b7d7ea995dc7285889b\",\"d9a09c9bde2303cd99c5795479ac606baeeeb0e56b872d40691c1a2b5c124fd7\",\"ddc1fc18310285e78ff40c5c18620cd111c2e3c82b77e33232703836782b3785\",\"a44b1f8d0a11dd1b3a911b15b975af1745ba19f39f50e4ccaaa39e972cef0745\",\"edc7d06e5566c5cd191213893d12c4dff6c34126e8187b9a37a0db26e3732b50\",\"19194d8408f69956418c849e45c9f2093570c2458c39265a1d1cfc78ff3a0f87\",\"944443928e2b58b83f79668123ddd95b567b1bbd801703b51303ccbe242730f2\",\"50f5f64b741bd9330fafc27bc4f97a0375cc5021255565bb4893265951e96604\",\"9d7c722de13fdc3fdbccd46c2e7990186da232df654104e2a0a50128d9c0e644\",\"3ce47373f0b4c4c9c76a67d92ed7f55d0b10b0f71901adb1ffd5eb373bd84ca8\",\"3e8c41749e77fee38f15ccc82233bfe58cc3f6800bf8ceec64603c05900e7f0c\",\"1008fb19a4e8041f019e41ee3861bc4976b2018e68646b396bf1bfc525b81a80\",\"dec4a4ccfa495a5a2f928e6326ee45064ad30eb75bc8de609084160df06cf6a4\",\"a803ec707abdc1bcf0e8881444d717b07f88b0a61aae1971267fcd4749f71eac\",\"352d9ee015407a38e11eb02d3bf70feb015e4554cb853eb6c436a12705fa8d93\",\"8cd9d06e7fc03b539c71d157f4f53f865c44de0bfff10b3989d55ec9d678b99a\",\"c6c4c26f2da72599964159f492a2f15e4fb3b90b844e62dd218223443b0960e5\",\"ac6c663e82b2a9799dacc2d5df276bcfa4c83eb23470d45dd94b7e8871b3361d\",\"7f134d0dcbd6820b06cdbd209e53f4d3d7e4aaf5b1755c95df0b795b45794eba\",\"3d86210aa6decb4cfe6bb1bf8578f1d05e71e75ba93cf21bf8285644ed7673c0\",\"02333fb27f9e529d2ba37c599ca64a7cadf8f069eb6a759899627357b631cee7\",\"2a717ac2b3390ee012ff95952d46abb2559308dd533a573e866062e0aabd6b5f\",\"9d1642e30567e9c38dac680ff5be362cc1ab4345a62b5f1437d73bff6f3a784c\",\"43283562df1183c18a502830a04c534bf58eabe338e23e78dcbe4ec03a4ccbd5\",\"82fc4599d234344c8554b4cefa99324672b589dc4ccaf8f137da17f37e7395be\",\"01ed8827039da6c535ea0e9e45aae83b304cd269f64d7cc841e79c5e61047ef7\",\"93a8a35025f617c2e3ed60b31abc7142e1391e9a7944a4154595ebcde18f1a3b\",\"4880a4c00970de4efb4efe88bbfff358cabb40da53099e34b094d07d9a24377e\",\"c465559bf2b2d085ad608022d3686ac7a4e5b54b287f7a836afed8777403c885\",\"ab49336a6fd04b6a4d97151cde1677efdb61650077da8077e9e497223cc436cc\",\"4228fb582d0b9ee572c274cd90e496724ddd41fc2daf4fb55360d1a9ab34d895\"],\"total\":10000}\n",
      "{'Date': 'Fri, 14 Mar 2025 02:06:17 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Access-Control-Expose-Headers': 'X-Rate-Limit-Policy, X-Rate-Limit-Rules, X-Rate-Limit-Ip, X-Rate-Limit-Ip-State', 'X-Rate-Limit-Policy': 'trade-search-request-limit', 'X-Rate-Limit-Rules': 'Ip', 'X-Rate-Limit-Ip': '5:10:60,15:60:300,30:300:1800', 'X-Rate-Limit-Ip-State': '1:10:0,1:60:0,1:300:0', 'X-Frame-Options': 'SAMEORIGIN', 'Strict-Transport-Security': 'max-age=63115200; includeSubDomains; preload', 'Content-Encoding': 'gzip', 'cf-cache-status': 'DYNAMIC', 'vary': 'accept-encoding', 'Server': 'cloudflare', 'CF-RAY': '92003600de6f4e0a-MCI'}\n"
     ]
    }
   ],
   "source": [
    "res = session.session.post(\n",
    "        url,\n",
    "        json=payload,\n",
    "        headers=headers\n",
    "    )\n",
    "print(res.status_code)\n",
    "print(res.text)\n",
    "print(res.headers)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2025-03-16 12:29:13,522 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): www.pathofexile.com:443\n",
      "2025-03-16 12:29:13,637 - urllib3.connectionpool - DEBUG - https://www.pathofexile.com:443 \"GET /api/trade2/fetch/483859b4f505b50dbaefdb3d12b1e2295a024d4e0e78d2131fbc39c40a577da5 HTTP/11\" 200 None\n",
      "2025-03-16 12:29:13,639 - rateLimiter - DEBUG - Waiting for 2.0999999999999996 | RateLimiter<max=16:window=12:penalty=300>, RateLimiter<max=1:window=12:penalty=0>\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "< GET /api/trade2/fetch/483859b4f505b50dbaefdb3d12b1e2295a024d4e0e78d2131fbc39c40a577da5 HTTP/1.1\n",
      "< Host: www.pathofexile.com\n",
      "< User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36 FirePHP/4Chrome\n",
      "< Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\n",
      "< Accept-Language: en-US,en;q=0.9\n",
      "< Accept-Encoding: gzip, deflate\n",
      "< \n",
      "\n",
      "> HTTP/1.1 200 OK\n",
      "> Date: Sun, 16 Mar 2025 17:29:29 GMT\n",
      "> Content-Type: application/json\n",
      "> Transfer-Encoding: chunked\n",
      "> Connection: keep-alive\n",
      "> Set-Cookie: POESESSID=024ce9f81404eef700392d0ca651bcb2; path=/; domain=.pathofexile.com; secure; HttpOnly; SameSite=Lax\n",
      "> Access-Control-Expose-Headers: X-Rate-Limit-Policy, X-Rate-Limit-Rules, X-Rate-Limit-Ip, X-Rate-Limit-Ip-State\n",
      "> X-Rate-Limit-Policy: trade-fetch-request-limit\n",
      "> X-Rate-Limit-Rules: Ip\n",
      "> X-Rate-Limit-Ip: 12:4:10,16:12:300\n",
      "> X-Rate-Limit-Ip-State: 1:4:0,1:12:0\n",
      "> X-Frame-Options: SAMEORIGIN\n",
      "> Strict-Transport-Security: max-age=63115200; includeSubDomains; preload\n",
      "> Content-Encoding: gzip\n",
      "> cf-cache-status: DYNAMIC\n",
      "> vary: accept-encoding\n",
      "> Server: cloudflare\n",
      "> CF-RAY: 9215f9168b7cd30a-MCI\n",
      "> \n",
      "{\"result\":[{\"id\":\"483859b4f505b50dbaefdb3d12b1e2295a024d4e0e78d2131fbc39c40a577da5\",\"listing\":{\"method\":\"psapi\",\"indexed\":\"2025-03-09T23:34:57Z\",\"stash\":{\"name\":\"Comércio\",\"x\":0,\"y\":10},\"whisper\":\"@ThiRP_Monk Hi, I would like to buy your Corpse Locket Heavy Belt listed for 1 transmute in Standard (stash tab \\\"Comércio\\\"; position: left 1, top 11)\",\"account\":{\"name\":\"ThiagoRP#6830\",\"online\":{\"league\":\"Standard\"},\"lastCharacterName\":\"ThiRP_Monk\",\"language\":\"en_US\",\"realm\":\"poe2\"},\"price\":{\"type\":\"~price\",\"amount\":1,\"currency\":\"transmute\"}},\"item\":{\"realm\":\"poe2\",\"verified\":true,\"w\":2,\"h\":1,\"icon\":\"https://web.poecdn.com/gen/image/WzI1LDE0LHsiZiI6IjJESXRlbXMvQmVsdHMvQmFzZXR5cGVzL0JlbHQwOSIsInciOjIsImgiOjEsInNjYWxlIjoxLCJyZWFsbSI6InBvZTIifV0/3299e86495/Belt09.png\",\"league\":\"Standard\",\"id\":\"483859b4f505b50dbaefdb3d12b1e2295a024d4e0e78d2131fbc39c40a577da5\",\"name\":\"Corpse Locket\",\"typeLine\":\"Heavy Belt\",\"baseType\":\"Heavy Belt\",\"rarity\":\"Rare\",\"ilvl\":61,\"identified\":true,\"note\":\"~price 1 transmute\",\"properties\":[{\"name\":\"Belt\",\"values\":[],\"displayMode\":0},{\"name\":\"Charm Slots\",\"values\":[[\"1\",0]],\"displayMode\":0}],\"requirements\":[{\"name\":\"Level\",\"values\":[[\"50\",0]],\"displayMode\":0,\"type\":62}],\"implicitMods\":[\"22% increased [StunThreshold|Stun Threshold]\"],\"explicitMods\":[\"+15 to maximum Mana\",\"11% reduced [Flask|Flask] Charges used\",\"+111 to [StunThreshold|Stun Threshold]\",\"14% increased [Flask|Flask] Charges gained\"],\"frameType\":2,\"extended\":{\"mods\":{\"explicit\":[{\"name\":\"of Restocking\",\"tier\":\"S2\",\"level\":16,\"magnitudes\":[{\"hash\":\"explicit.stat_1836676211\",\"min\":\"11\",\"max\":\"16\"}]},{\"name\":\"Cobalt\",\"tier\":\"P2\",\"level\":6,\"magnitudes\":[{\"hash\":\"explicit.stat_1050105434\",\"min\":\"15\",\"max\":\"24\"}]},{\"name\":\"of Imbibing\",\"tier\":\"S2\",\"level\":18,\"magnitudes\":[{\"hash\":\"explicit.stat_644456512\",\"min\":\"13\",\"max\":\"11\"}]},{\"name\":\"of Granite Skin\",\"tier\":\"S6\",\"level\":36,\"magnitudes\":[{\"hash\":\"explicit.stat_915769802\",\"min\":\"98\",\"max\":\"124\"}]}],\"implicit\":[{\"name\":\"\",\"tier\":\"\",\"level\":63,\"magnitudes\":[{\"hash\":\"implicit.stat_680068163\",\"min\":\"20\",\"max\":\"30\"}]}]},\"hashes\":{\"explicit\":[[\"explicit.stat_1050105434\",[1]],[\"explicit.stat_644456512\",[2]],[\"explicit.stat_915769802\",[3]],[\"explicit.stat_1836676211\",[0]]],\"implicit\":[[\"implicit.stat_680068163\",[0]]]}}}}]}\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2025-03-16 12:29:15,740 - rateLimiter - DEBUG - Current rate limits: defaultdict(None, {'trade-search-request-limit': {'policy': 'trade-search-request-limit', 'rules': 'Ip', 'limit': '5:10:60,15:60:300,30:300:1800', 'state': '1:10:0,1:60:0,1:300:0', 'rate_limits': [(RateLimiter<max=30:window=300:penalty=1800>, RateLimiter<max=1:window=300:penalty=0>), (RateLimiter<max=15:window=60:penalty=300>, RateLimiter<max=1:window=60:penalty=0>), (RateLimiter<max=5:window=10:penalty=60>, RateLimiter<max=1:window=10:penalty=0>)], 'last_update': datetime.datetime(2025, 3, 16, 12, 28, 28, 250926), 'prev_state': None, 'prev_rate_limits': None}, 'trade-fetch-request-limit': {'policy': 'trade-fetch-request-limit', 'rules': 'Ip', 'limit': '12:4:10,16:12:300', 'state': '1:4:0,1:12:0', 'rate_limits': [(RateLimiter<max=16:window=12:penalty=300>, RateLimiter<max=1:window=12:penalty=0>), (RateLimiter<max=12:window=4:penalty=10>, RateLimiter<max=1:window=4:penalty=0>)], 'last_update': datetime.datetime(2025, 3, 16, 12, 29, 13, 639136), 'prev_state': None, 'prev_rate_limits': None}})\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "session.get(\"https://www.pathofexile.com/api/trade2/fetch/483859b4f505b50dbaefdb3d12b1e2295a024d4e0e78d2131fbc39c40a577da5\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
